package com.zhouyibike.uu.ui.activity.hehuoren;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

import com.zhouyibike.uu.R;
import com.zhouyibike.uu.entity.HehuorenxuanzejiemianResult;
import com.zhouyibike.uu.ui.adapter.SelectHehuorenAdapter;
import com.zhouyibike.uu.ui.base.BaseActivity;

import java.util.ArrayList;

public class SelectHehuorenActivity extends BaseActivity {
    private ImageButton mBtnBack;
    private TextView mBtnTitle;
    private ListView lv;
    private SelectHehuorenAdapter adapter;
    private ArrayList<HehuorenxuanzejiemianResult> list = new ArrayList<>();
    private TextView textView2;
    private int curint=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_selecthehuoren);
        initview();
        getMsg();
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                if (list.get(i).ischeck) {
                    list.get(i).ischeck = true;
                } else {
                    for (int z = 0; z < list.size(); z++) {
                        list.get(z).ischeck = false;
                    }
                    list.get(i).ischeck = true;
                }
                curint=i;
                adapter.notifyDataSetChanged();
            }
        });
        textView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                toastShow(curint+"beixuanzhongle");
            }
        });
    }

    private void initview() {
        lv = (ListView) findViewById(R.id.selecthehuoren_lv);
        mBtnBack = (ImageButton) findViewById(R.id.bar_btn_back);
        mBtnTitle = (TextView) findViewById(R.id.bar_text_title);
        mBtnTitle.setText("区域合伙人");
        textView2 = (TextView) findViewById(R.id.textView2);
    }

    private void getMsg() {
        list = new ArrayList<>();
        for (int i = 0; i <4 ; i++) {
            HehuorenxuanzejiemianResult hehuorenxuanzejiemianResult = new HehuorenxuanzejiemianResult();
            if(i==0)
            {
                hehuorenxuanzejiemianResult.ischeck=true;
            }else {
                hehuorenxuanzejiemianResult.ischeck=false;
            }
            if (i==0)
            {
                hehuorenxuanzejiemianResult.itemname="省级区域合伙人";
                hehuorenxuanzejiemianResult.itemhavegoodlist=new ArrayList<>();
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("享受区域内3%所有业绩分红");
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("单车骑行收益");
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("专属后台");
            }else if (i==1)
            {  hehuorenxuanzejiemianResult.itemname="市级区域合伙人";
                hehuorenxuanzejiemianResult.itemhavegoodlist=new ArrayList<>();
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("享受区域内3%所有业绩分红");
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("单车骑行收益");
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("专属后台");
            }else if(i==2)
            {  hehuorenxuanzejiemianResult.itemname="区/县级区域合伙人";
                hehuorenxuanzejiemianResult.itemhavegoodlist=new ArrayList<>();
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("享受区域内5%所有业绩分红");
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("单车骑行收益");
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("专属后台");
            }else{  hehuorenxuanzejiemianResult.itemname="省单车合伙人";
                hehuorenxuanzejiemianResult.itemhavegoodlist=new ArrayList<>();
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("单车骑行收益");
                hehuorenxuanzejiemianResult.itemhavegoodlist.add("1080张骑行券");
            }
            list.add(hehuorenxuanzejiemianResult);
        }
        adapter = new SelectHehuorenAdapter(this, list);
        lv.setAdapter(adapter);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 200 && resultCode == 789) {

        }
    }
}
